home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.09 Sep 88 / 4d stuff / Source Files / SoundToPict.p < prev    next >
Encoding:
Text File  |  1988-06-22  |  1.3 KB  |  60 lines  |  [TEXT/MPS ]

  1. Program Ext_SoundToPict;
  2.  
  3. Uses MemTypes, QuickDraw, OSIntf,
  4.         ToolIntf, PackIntf, Sound;
  5.  
  6. Var
  7.     DFile, DSound:str255;
  8.     DPict:PicHandle;
  9.  
  10. procedure SoundToPict(
  11.     var TheFile, SoundName:str255;
  12.     var MyPict:PicHandle);
  13.  
  14. type
  15.     FFSynthHandle = ^FFSynthPtr;
  16.  
  17. var
  18.     MySound:FFSynthHandle;
  19.     TheRes:integer;
  20.     MyPtr:Ptr;
  21.     MyFFPtr:FFSynthPtr;
  22.  
  23. begin
  24.     MyPict:=Nil;
  25.     TheRes:=OpenResFile(TheFile);
  26.     MySound:=FFSynthHandle(GetNamedResource
  27.     ('Snd ',SoundName));  {Locate SND}
  28.     {Test if the sound was found and read}
  29.     if MySound<>Nil then
  30.     begin
  31.         Hlock(Handle(MySound));
  32.         {Copy the Pointer}
  33.         MyPtr:=Ptr(MySound^);
  34.         {Type coerce the new Ptr}
  35.         MyFFPtr:=FFSynthPtr(MyPtr);
  36.         {Set the playback mode and ratio}
  37.         MyFFPtr^.mode:=FFMode;
  38.         MyFFPtr^.count:=FixRatio(1,1);
  39.         MyFFPtr^.wavebytes[0]:=0;
  40.         {Type coerce the handle to type}
  41.         {PicHandle}
  42.         MyPict:=Pichandle(MySound);
  43.         {Lock the picture so we don't lose it}
  44.         HLock(Handle(MyPict));
  45.         {Coerce and Copy the pointer}
  46.         MyPict^:=PicPtr(MyPtr);
  47.         {Unlock the Handles before leaving}
  48.         HUnlock(Handle(MySound));
  49.         Hunlock(Handle(MyPict));
  50.         {Now Detach the Resource since we}
  51.         {have another handle to it.}
  52.         DetachResource(Handle(MySound));
  53.     end;    {if mysound<>Nil}
  54.     CloseResFile(TheRes);
  55. end;        {SoundToPict}
  56.  
  57. Begin
  58.     SoundToPict(DFile, DSound, DPict);
  59. End.        {Main Block}
  60.